<template>
  <div class="detailPageCss">
    <div class="titleCss">查看上交资料</div>
    <div class="bodyCss">
      <div class="centerBtnCss">
        <el-button type="primary" @click="configBtn">配置上传周期</el-button>
      </div>
      <div class="tableCss">
        <el-table
          max-height="520"
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            type="index"
            label="序号"
            width="55"
            align="center">
          </el-table-column>
          <el-table-column
            prop="data1"
            label="协管员名称"
            min-width="100">
            <template #default="scope">
              <span :style="scope.row.data4 ? 'color:red;' : ''">
                {{ scope.row.data1 }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="data2"
            label="资料类型"
            min-width="150">
            <template #default="scope">
              <span :style="scope.row.data4 ? 'color:red;' : ''">
                {{ data2Map[scope.row.data2] }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            prop="data3"
            label="最新一次上传时间"
            min-width="100">
            <template #default="scope">
              <span :style="scope.row.data4 ? 'color:red;' : ''">
                {{ scope.row.data3 + ( scope.row.data4 ? '（超时未上传）' : '' ) }}
              </span>
            </template>
          </el-table-column>
          <el-table-column
            fixed="right"
            label="操作"
            width="240">
            <template #default="scope">
              <el-button @click="lookNewBtn(scope.row)" type="text" size="small">查看最新上传详情</el-button>
              <el-button @click="lookOldBtn(scope.row)" type="text" size="small">查看过往上传内容</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          style="margin-top:10px;text-align: right;"
          background
          :pageSize="pageSize"
          layout="prev, pager, next"
          :page-sizes="[10, 20, 50]"
          :total="total"
          @sizeChange="handleSizeChange"
          @currentChange="handleCurrentChange">
        </el-pagination>
      </div>
    </div>
    <div class="bottomBtnCss">
      <el-button @click="goBackBtn">返回</el-button>
    </div>
  </div>
</template>

<script>
import { getCurrentDay } from '@/utils/business.js'
export default {
  data(){
    return{
      tableData:[],
      pageSize:10,
      total:1000,
      data2Map:{
        0:'卫生监督协管信息报告记录表',
        1:'卫生监督协管信息报送表',
        2:'卫生监督协管巡查工作记录表',
        3:'卫生监督协管教育宣传培训汇总表',
        4:'卫生监督协管健康教育活动记录表',
        5:'基本公共卫生服务职业卫生咨询宣传工作记录表',
        6:'公共场所卫生监督巡查记录表',
        7:'生活饮用水卫生监督巡查记录表',
        8:'医疗卫生监督巡查记录表',
        9:'放射卫生监督巡查记录表',
      }
    }
  },
  mounted(){
    this.getList()
  },
  methods:{
    handleCurrentChange(){
      
    },
    handleSizeChange(){
      
    },
    lookOldBtn(row){

    },
    lookNewBtn(row){

    },
    getList(){
      const random = Math.floor( Math.random() * 60) + 1
      this.tableData = []
      for( let i=0;i<random ; i++){
        const random1 = Math.floor( Math.random() * 10)
        const random2 = Math.floor( Math.random() * 3)
        this.tableData.push({
          data1: '张三',
          data2: random1,
          data3: getCurrentDay(),
          data4: !Boolean(random2)
        })
      }
    },
    configBtn(){
      const obj = {
        path: '/dataIntegration/test4/lookFile/config',
        query: {
          id: '111',
        }
      }
      this.$router.push(obj);
    },
    goBackBtn(){
      this.$router.back()
    },
  },
}
</script>

<style lang="scss" scoped>
.detailPageCss{
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  height: calc( 100vh - 66px - 40px);
  display: flex;
  flex-direction: column;
  .titleCss{
    text-align: center;
    font-size: 18px;
    font-weight: bold;
  }
  .bodyCss{
    width: calc( 100% - 20px);
    margin-top: 40px;
    margin-left: 10px;
    .centerBtnCss{
      position: relative;
    }
    .tableCss{
      margin-top: 20px;
    }
  }
  .bottomBtnCss{
    margin-top: auto;
    text-align: right;
  }
}
</style>